home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Diamond Collection
/
The Diamond Collection (Software Vault)(Digital Impact).ISO
/
cdr48
/
386p_200.zip
/
PCSPEAK.ASM
< prev
next >
Wrap
Assembly Source File
|
1995-01-13
|
7KB
|
174 lines
; DO NOT USE THIS, I JUST STARTED RECODING IT FOR XSD
align dword
; current sound data
_SoundLen dd 0 ; default = zero sound lenght
_SoundPtr dd 0 ; default = null, points to already decode sound data
; the installed sound driver must play
; default sound data
_DSoundLen dd 0 ; default = zero , default sound lenght
_DSoundPtr dd 0 ; default = null , default sound
align byte
_SoundOn db 0 ; Set this to turn on sound generation, all sound driver must
; refer to this flag to control sound output
_DSoundOn db 0 ;ditto for the default sound insertion at end of sound
Buzzing db 0 ; are we currently producing sound ? (private var.)
; decrementi di contatore usati come riferimento
PWMTICK = 149 ; conteggio equivalente a 8008Hz
public _InstallPWM
_InstallPWM:
; install irqs & set up voc_table
pushad
; initialize internal vars
mov Buzzing,0
mov _SoundOn,0
mov _DSoundOn,0
mov _SoundLen,0
mov _SoundPtr,0
mov _DSoundLen,0
mov _DSoundPtr,0
; set voc_table
mov esi,offset pwm_table
mov edi,offset voc_table
mov eax,0
mov ecx,64
set_up_voc_table:
movsd
dec ecx
jne set_up_voc_table
cli
; first install the real mode side
cmp _386Man,IS_DPMI
je @nopwreflex
mov al,21h
mov V86ax,2508h
mov V86ds,code16
mov V86dx,offset code16:IRQ0_RISR
int 33h
@nopwreflex:
; then the protected mode side (it works only this way in DPMI)
mov bl,0
mov edx,offset IRQ0_ISR
call _SetIRQ
mov ebx,F8008 ; 8008Hz count
cmp _386Man,IS_DPMI
jne @vcpispeed
shl ebx,1 ; freq to 4004Hz
@vcpispeed:
mov play_rate,ebx ; set playback frequency for voc converter
mov al,T_SET0 ; set programmable interval timer 0 to 8008Hz or 4004Hz
out PIT_CTRL,al ;
mov al,bl ;
out PIT0,al ;
mov al,bh ;
out PIT0,al ;
sti
; no need to initialize time counters
; InstallPFLP already did it
popad
ret
; PWM SOUND SPEAKER DRIVER
zarp_sound:
cmp _DSoundOn,0
je dont_buzz
mov eax,_DSoundLen
dec eax
mov ebx,_DSoundPtr
mov _SoundLen,eax
jmp doit_again
dont_buzz:
cmp Buzzing,0
je getoutsound
mov Buzzing,0
; turn speaker OFF
in al, 61h ;Read I/O port B into AL
and al, 11111100b ;mask lower two bits
out 61h, al ;to turn off speaker
pop ebx
pop eax
ret
DoTheSound:
push eax
push ebx
; ds is on correct segment
cmp _SoundOn,0
je dont_buzz ; no sound if sound flag is off
cmp _SoundLen,0
je zarp_sound ; no sound if at end of "soundtrack"
dec _SoundLen ; decrease "soundtrack" lenght
mov ebx,_SoundPtr ;get current count pointer
doit_again:
mov al,[ebx] ; count into AX
inc ebx ; & update sound pointer
mov _SoundPtr,ebx ; (only offset is changed)
mov ah,al ; copy count
or al,al ; zero count sets speaker off
;je dont_buzz ;
mov al,P_SET2S
out PIT_CTRL,al
mov al,ah
out PIT2, al
cmp Buzzing,0
jne getoutsound
mov Buzzing,1
; turn sound on
in al, 61h ;read I/O port B into AL
or al,3 ;turn on bits 0 and 1
out 61h,al ;to turn on speaker
getoutsound:
pop ebx
pop eax
ret
;-----------------------------------------------------------------------------
; 8bit, not compressed VOC to "raw 8 bit pcm"
align dword
voc_rate dd ?
play_rate dd ? ; playback sample rate and IRQ0 frequency under PWM sound
align byte
pwm_table db 1 , 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20
db 21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30
db 31,31,31,32,32,32,33,33,33,34,34,34,35,35,35,36,36,36,37,37
db 37,38,38,38,39,39,39,40,40,40,41,41,41,42,42,42,43,43,43,44
db 45,45,45,46,46,46,47,47,47,48,48,48,49,49,49,50,50,50,51,51
db 51,52,52,52,53,53,53,54,54,54,55,55,55,56,56,56,57,57,57,57
db 58,58,58,58,59,59,59,59,60,60,60,60,61,61,61,61,62,62,62,62
db 63,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66
db 67,67,67,67,67,68,68,68,68,68,69,69,69,69,69,70,70,70,70,70
db 71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72
db 73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74
db 75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75
db 75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75
voc_table db 1 , 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20
db 21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30
db 31,31,31,32,32,32,33,33,33,34,34,34,35,35,35,36,36,36,37,37
db 37,38,38,38,39,39,39,40,40,40,41,41,41,42,42,42,43,43,43,44
db 45,45,45,46,46,46,47,47,47,48,48,48,49,49,49,50,50,50,51,51
db 51,52,52,52,53,53,53,54,54,54,55,55,55,56,56,56,57,57,57,57
db 58,58,58,58,59,59,59,59,60,60,60,60,61,61,61,61,62,62,62,62
db 63,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66
db 67,67,67,67,67,68,68,68,68,68,69,69,69,69,69,70,70,70,70,70
db 71,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72
db 73,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74
db 75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75
db 75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75